//
//  ViewController.m
//  BarCode
//
//  Created by Hunk on 12-2-7.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "ViewController.h"

@implementation ViewController

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    
    // Init BarCodeController
    barCodeController = [[BarCodeController alloc] init];
    [barCodeController setDelegate:self];
    [barCodeController setDataSource:self];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [button setFrame:CGRectMake(100.0, 100.0, 100.0, 30.0)];
    [button setTitle:@"AAA" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(Handle) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    
}

- (UIView *)barCodeOverlayView:(BarCodeController *)barCodeContoller
{
    return nil;
}

- (void)didFinishScan:(BarCodeController *)barCodeContoller result:(NSString *)result image:(UIImage *)image
{
    NSLog(@"result:%@\n", result);
}

- (void)Handle
{
    [barCodeController scanBarCodeOnViewController:self];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
	[super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated
{
	[super viewDidDisappear:animated];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

@end
